package com.nacl.qwen.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author nacl
 * @since 2024/8/20
 **/
@RestController
public class Controller {
    @Resource
    private ChatClient chatClient;

    @GetMapping("/ai/chat")
    public String chat(@RequestParam(value = "message", defaultValue = "你是谁") String message) {
        Prompt prompt = new Prompt(message);
        return chatClient.call(prompt).getResult().getOutput().getContent();
    }
}
